package com.lzw.service.impl;

import com.lzw.dao.UserDao;
import com.lzw.pojo.User;
import com.lzw.service.UserService;
import com.lzw.until.MyBatisUntil;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Transactional
@Service("us")
public class UserServiceImpl implements UserService {
    //声明一个功能接口的对象
    @Autowired
    private UserDao ud;
    @Override
    @Transactional(propagation = Propagation.REQUIRED )
    public User login(String uname, String upwd) {
        //调用登录的方法:
        User user = ud.login(uname,upwd);
        return user;
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED )
    //alt加enter导入方法
    public boolean ZhuCe(User user) {
        int num=ud.ZhuCe(user);
        if(num>0){
            return true;
        }
        return false;    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED )
    public List<User> selectAll() {
        List<User> list=ud.selectAll();
        return null;
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED )
    public List<User> selectAllUname() {
        List<User> list=ud.selectAllUname();
        return null;
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS,isolation = Isolation.SERIALIZABLE)
    public User getUserByName(String uname) {
        //执行功能:
        User user = ud.getUserByName(uname);
        return user;//代表用户不存在
    }
        @Override
    @Transactional(propagation = Propagation.REQUIRED )
    public boolean updateUser(User user) {
        int num=ud.updateUser(user);
        if(num>0){
            return true;
        }
        return false;
    }


}
